package com.SmartCare.controller.client;

import com.SmartCare.common.Result;
import com.SmartCare.pojo.medicine.Medication;
import com.SmartCare.service.medicine.MedicationFrequencyService;
import com.SmartCare.service.medicine.MedicationService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/client")
@Api(tags = "C端用药记录")
@Slf4j
public class MedicineController {
    @Resource
    private MedicationService medicationService;

    @Resource
    private MedicationFrequencyService medicationFrequencyService;

    /**
     * 所有药品名称查询 用于填充药物名称下拉框
     */
    @GetMapping("/medicineName/query")
    public Result medicineNameQuery() {
        return medicationService.medicineNameQuery();
    }

    /**
     * 推荐药品信息查询
     */
    @GetMapping("/medicine/query")
    public Result medicineQuery(@RequestParam(required = false) String name) {
        return medicationService.medicineQuery(name);
    }

    /**
     * 服药频率推荐信息查询
     */
    @GetMapping("/frequency/query")
    public Result frequencyQuery() {
        return medicationFrequencyService.frequencyQuery();
    }


    /**
     * 添加药品信息
     */
    @PostMapping("/medicine/add")
    public Result addMedicine(@RequestBody Medication medication) {
        return medicationService.addMedicine(medication);
    }

}
